QString rot13(const QString& s);
-/*
- * PalmOS records like fixed-point numbers, which should be rounded
- * to deal with possible floating-point representation errors.
- */
-
-signed int si_round(double d);
-
/*
* Prototypes for Endianness helpers.
*/
#include <QTextStream> // for QTextStream
#include <QVector> // for QVector
#include <Qt> // for CaseInsensitive
-#include <QtGlobal> // for qPrintable
+#include <QtGlobal> // for qRound, qPrintable
#include "csv_util.h" // for csv_linesplit
#include "formspec.h" // for FormatSpecificDataList
print_course(const Waypoint* A, const Waypoint* B) /* seems to be okay */
{
if ((A != nullptr) && (B != nullptr) && (A != B)) {
- int course = si_round(waypt_course(A, B));
+ int course = qRound(waypt_course(A, B));
*fout << QString::asprintf("%d° true", course);
}
}
if (dist < 100.0) {
*fout << QString::asprintf("%.1f mi", dist);
} else {
- *fout << QString::asprintf("%d mi", si_round(dist));
+ *fout << QString::asprintf("%d mi", qRound(dist));
}
}
} else {
if (dist < 100.0) {
*fout << QString::asprintf("%.1f km", dist);
} else {
- *fout << QString::asprintf("%d km", si_round(dist));
+ *fout << QString::asprintf("%d km", qRound(dist));
}
}
}
} else {
unit = "kph";
}
- int idist = si_round(dist);
+ int idist = qRound(dist);
if ((*time != 0) && (idist > 0)) {
double speed = MPS_TO_KPH(dist / (double)*time);
- int ispeed = si_round(speed);
+ int ispeed = qRound(speed);
if (speed < 0.01) {
*fout << QString::asprintf("0 %s", unit);
#include <QByteArray> // for QByteArray
#include <QDateTime> // for QDateTime
-#include <QtGlobal> // for qPrintable
+#include <QtGlobal> // for qRound, qPrintable
#include <QXmlStreamAttributes> // for QXmlStreamAttributes
#include <cstdarg> // for va_end, va_list, va_start
}
if (tdata.avg_hrt) {
gtc_write_xml(1, "<AverageHeartRateBpm xsi:type=\"HeartRateInBeatsPerMinute_t\">\n");
- gtc_write_xml(0, "<Value>%d</Value>\n", (int)(*tdata.avg_hrt + 0.5));
+ gtc_write_xml(0, "<Value>%d</Value>\n", qRound(*tdata.avg_hrt));
gtc_write_xml(-1,"</AverageHeartRateBpm>\n");
}
if (tdata.max_hrt) {
}
gtc_write_xml(0, "<Intensity>Active</Intensity>\n");
if (tdata.avg_cad) {
- gtc_write_xml(0, "<Cadence>%d</Cadence>\n", (int)(*tdata.avg_cad + 0.5));
+ gtc_write_xml(0, "<Cadence>%d</Cadence>\n", qRound(*tdata.avg_cad));
}
if (!gtc_course_flag) { /* activity (history) format */
#include <QMap> // for QMap
#include <Qt> // for CaseInsensitive
+#include <QtGlobal> // for qRound
#include <cmath> // for atan, tan, M_PI, log, sinh
#include <cstdio> // for snprintf, SEEK_SET
#include <cstring> // for strncpy, memcpy, memset
-#include "defs.h" // for Waypoint, be_read32, be_read16, be_write32, fatal, xfree, be_write16, route_head, si_round, xcalloc, track_add_wpt, xstrndup, mkshort, mkshort_del_handle, mkshort_new_handle, setshort_badchars, setshort_defname, setshort_length, setshort_mustuniq, setshort_...
+#include "defs.h" // for Waypoint, be_read32, be_read16, be_write32, fatal, xfree, be_write16, route_head, xcalloc, track_add_wpt, xstrndup, mkshort, mkshort_del_handle, mkshort_new_handle, setshort_badchars, setshort_defname, setshort_length, setshort_mustuniq, setshort_...
#include "src/core/datetime.h" // for DateTime
}
}
- hum.depth = si_round(WAYPT_GET(wpt, depth, 0)*100.0);
+ hum.depth = qRound(WAYPT_GET(wpt, depth, 0)*100.0);
be_write16(&hum.depth, hum.depth);
be_write32(&hum.time, wpt->GetCreationTime().toTime_t());
double east = wpt->longitude / 180.0 * EAST_SCALE;
- be_write32(&hum.east, si_round((east)));
+ be_write32(&hum.east, qRound((east)));
double lat = geodetic_to_geocentric_hwr(wpt->latitude);
double north = inverse_gudermannian_i1924(lat);
- be_write32(&hum.north, si_round(north));
+ be_write32(&hum.north, qRound(north));
QString name = (global_opts.synthesize_shortnames)
? mkshort_from_wpt(wptname_sh, wpt)
int i = trk_head->num_points;
- int32_t east = si_round(wpt->longitude / 180.0 * EAST_SCALE);
+ int32_t east = qRound(wpt->longitude / 180.0 * EAST_SCALE);
double lat = geodetic_to_geocentric_hwr(wpt->latitude);
- int32_t north = si_round(inverse_gudermannian_i1924(lat));
+ int32_t north = qRound(inverse_gudermannian_i1924(lat));
if (wpt->creation_time.isValid()) {
last_time = wpt->GetCreationTime().toTime_t();
int j = i-1;
trk_points[j].deltaeast = east - last_east;
trk_points[j].deltanorth = north - last_north;
- trk_points[j].depth = si_round(WAYPT_GET(wpt, depth, 0)*100.0);
+ trk_points[j].depth = qRound(WAYPT_GET(wpt, depth, 0)*100.0);
/* BE-ify */
be_write16(&trk_points[j].deltaeast, trk_points[j].deltaeast);
#include <QVector> // for QVector
#include <QXmlStreamAttributes> // for QXmlStreamAttributes
#include <Qt> // for ISODate
-#include <QtGlobal> // for foreach, qint64, qPrintable
+#include <QtGlobal> // for foreach, qint64, qRound, qPrintable
#include "defs.h"
#include "kml.h"
value = QStringLiteral("%1-none").arg(style);
} else {
value = QStringLiteral("%1-%2").arg(style)
- .arg((int)(waypointp->course / 22.5 + .5) % 16);
+ .arg(qRound(waypointp->course / 22.5) % 16);
}
writer->writeTextElement(QStringLiteral("styleUrl"), value);
} else {
p[3] = value >> 24;
}
-signed int
-si_round(double d)
-{
- if (d < 0) {
- return (signed int)(d-0.5);
- } else {
- return (signed int)(d+0.5);
- }
-}
-
/*
mkgmtime -- convert tm struct in UTC to time_t
#include <QString> // for QString, operator+, operator==
#include <QStringList> // for QStringList
#include <QTextStream> // for QTextStream
-#include <QtGlobal> // for qAsConst, qPrintable
+#include <QtGlobal> // for qAsConst, qRound, qPrintable
#include "defs.h"
#include "csv_util.h" // for csv_stringtrim, dec_to_human, csv_stringclean, human_to_dec, ddmmdir_to_degrees, dec_to_intdeg, decdir_to_dec, intdeg_to_dec, csv_linesplit
if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map))
fatal(MYNAME ": Position (%.5f/%.5f) outside of BNG.\n",
wpt->latitude, wpt->longitude);
- buff = QString::asprintf(fmp.printfc.constData(), map, (int)(east + 0.5), (int)(north + 0.5));
+ buff = QString::asprintf(fmp.printfc.constData(), map, qRound(east), qRound(north));
}
break;
case XcsvStyle::XT_UTM: {